--
-- Author: yawei.zhu
-- Date: 2018-07-03 14:41:58
--
-- OtherPlayerRender
--

local ClassRef = app.mvc.createRenderClass(...)

--data =
function ClassRef.createWithData(data, node)
    local sprite = ClassRef.extend(node or cc.CSLoader:createNode(Res.OtherPlayerCountNode))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init(data)
    return sprite
end
function ClassRef.create(node)
    return ClassRef.createWithData(nil, node)
end

--
function ClassRef:init(data)
    self.super.init(self, data)
    self:setContentSize(self._ui.bg:getContentSize())

    self:refresh()
end

function ClassRef:refresh()
    if self._data and self._data[2] then
        self:setVisible(true)

        local data = self._data[2]
        self._ui.name:setString(L(data.name))
        self._ui.Text:setString(data.value)
        local path = Res.statisticPath .. data.icon .. ".png"
        self._ui.icon:loadTexture(path)
    else
        self:setVisible(false)
    end
end

function ClassRef:onBtnClick(cb)
    self._onClick = cb
end

return ClassRef
